<script setup>
import { useSubjectStore } from '@/stores'
const subjectStore = useSubjectStore()
const setSAE = (data) => {
  subjectStore.setSAE(data).then((code) => {
    if (code === true) {
      ElMessage.success('成功')
    } else {
      ElMessage.error('失败')
    }
  })
}
const degree = [
  {
    value: 1,
    label: '轻度'
  },
  {
    value: 2,
    label: '中度'
  },
  {
    value: 3,
    label: '重度'
  }
]
const conversions = [
  {
    label: '症状消失',
    options: [
      {
        value: 1,
        label: '有后遗症'
      },
      {
        value: 2,
        label: '无后遗症'
      }
    ]
  },
  {
    label: '症状持续',
    options: [
      {
        value: 3,
        label: '症状持续'
      }
    ]
  }
]
const situations = [
  {
    label: '国内',
    options: [
      {
        value: 1,
        label: '有'
      },
      {
        value: 2,
        label: '无'
      },
      {
        value: 3,
        label: '不详'
      }
    ]
  },
  {
    label: '国外',
    options: [
      {
        value: 4,
        label: '有'
      },
      {
        value: 5,
        label: '无'
      },
      {
        value: 6,
        label: '不详'
      }
    ]
  }
]
</script>
<template>
  <el-table :data="subjectStore.SAE" :style="{ width: '100%' }">
    <el-table-column prop="week" label="时间" width="40" />
    <el-table-column label="报告类型" width="120">
      <template #default="scope">
        <el-input v-model="scope.row.type" placeholder="请输入" />
      </template>
    </el-table-column>
    <el-table-column label="报告时间" width="120">
      <template #default="scope">
        <el-date-picker
          v-model="scope.row.date"
          type="date"
          placeholder="报告时间"
          style="width: 100%"
        />
      </template>
    </el-table-column>
    <el-table-column label="SAE发生时间" width="120">
      <template #default="scope">
        <el-date-picker
          v-model="scope.row.occurrenceDate"
          type="date"
          placeholder="发生时间"
          style="width: 100%"
        />
      </template>
    </el-table-column>
    <el-table-column label="SAE反应严重程度" width="124">
      <template #default="scope">
        <el-select
          v-model="scope.row.degree"
          placeholder="Select"
          style="width: 100px"
        >
          <el-option
            v-for="item in degree"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </template>
    </el-table-column>
    <el-table-column label="SAE转归" width="124">
      <template #default="scope">
        <el-select
          v-model="scope.row.conversion"
          placeholder="Select"
          style="width: 100px"
        >
          <el-option-group
            v-for="group in conversions"
            :key="group.label"
            :label="group.label"
          >
            <el-option
              v-for="item in group.options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-option-group>
        </el-select>
      </template>
    </el-table-column>
    <el-table-column label="SAE报告情况" width="124">
      <template #default="scope">
        <el-select
          v-model="scope.row.situation"
          placeholder="Select"
          style="width: 100px"
        >
          <el-option-group
            v-for="group in situations"
            :key="group.label"
            :label="group.label"
          >
            <el-option
              v-for="item in group.options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-option-group>
        </el-select>
      </template>
    </el-table-column>
    <el-table-column label="SAE发生及处理的详细情况" width="100">
      <template #default="scope">
        <el-input v-model="scope.row.handle" placeholder="请输入" />
      </template>
    </el-table-column>
    <el-table-column label="提交">
      <template #default="scope">
        <el-button @click="setSAE(scope.row)">确定</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>
